Now that we've seen how Prim's algorithm starts by greedily adding the first edge, let's frame this "growing" process with a helpful analogy: the expanding frontier.

  • Imagine the vertices already in our MST are part of a "settled territory". All other vertices are in the "unexplored frontier".
  • Our goal is to connect all territories using the minimum possible amount of road.
  • The edges that connect our settled territory to the unexplored frontier are "potential bridges".
  • At each step, Prim's algorithm acts like a cautious city planner. It surveys all possible bridges and always chooses to build the "cheapest, shortest bridge" to a new, unexplored territory.
  • Once the bridge is built, the new territory becomes "settled," and the process repeats with an expanded frontier until all territories are connected.
Algorithm Concept Analogy Component
Vertices in the MST 'Settled Territory'
Vertices not in the MST 'Unexplored Frontier'
Edges connecting the two sets 'Potential Bridges'
The minimum-weight crossing edge 'The Cheapest Bridge to Build Next'
The complete Minimum Spanning Tree 'All territories connected with minimum road cost'